#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/7/22  20:17
# @Author: 余浪人
# @email: yulangren520@gmail.com

from apps.models import db, BaseModel


class TL_Connector_Model(BaseModel):
    impower_code = db.Column(db.String(32), comment='授权码')

    def keys(self):
        return 'impower_code', 'status'


class TL_WebApp_Model(BaseModel):
    public_key = db.Column(db.String(512), comment='授权代码')
    private_code = db.Column(db.String(512), comment='授权码')
    public_pem = db.Column(db.String(512), comment='加密公钥')
    private_pem = db.Column(db.String(1024), comment='解密私钥')

    def keys(self):
        return 'status', 'public_key', 'private_code', 'public_pem'


class TL_Indexes_Model(BaseModel):
    indexes_design = db.Column(db.String(256), comment='索引结构')
    push_address = db.Column(db.String(256), comment='推送地址')
    indexes_num = db.Column(db.Integer, default=400, comment='索引数')

    def keys(self):
        return 'indexes_design', 'indexes_num'


class TL_ThemePush_Model(BaseModel):
    identifier = db.Column(db.String(256), comment='主题识别码')
    is_current = db.Column(db.Integer, default=0, comment='是否当前主题')

    def __repr__(self):
        return f'当前模板:<{self.identifier}>'
    def keys(self):
        return 'identifier', 'is_current'
